package com.itlzh.mall.common.config;


import com.itlzh.mall.common.interceptor.AuthorizationInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 配置类：表示Spring按照该配置类初始化容器
 * 该配置类用于配置拦截器，拦截所有请求
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    /**
     * 注册拦截器，可以注册多个拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new AuthorizationInterceptor())
                .addPathPatterns("/**") // 拦截所有地址
                .excludePathPatterns("/login","/user/register","/goods/**");// 排除拦截
    }
}
